#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"

#define STK_SZ 4096


//int * tmp;
//int * tans;
//struct BB * bbuffer;

/******
void * consume(void){
	int * elem;

	while(1){
		elem = (int *)semaphore_pop(bbuffer);
		printf(1,"Consume...%d\n", thread_getid());
		sleep(99);
	}

	return 0;
}

void * produce(void){
	//int myid;
	//myid = thread_getid();

	while(1){
		semaphore_put(bbuffer, 0);
		printf(1,"Produce!%d\n", thread_getid());
		sleep(100);
	}

	return 0;
}
*******/



int
main(int argc, char *argv[])
{
	/****
	int i;
	int num;
	int j;

	void * stack;
	int * threadsArr;


	tmp = &j;

	if (argc < 2){
		printf(2,"Usage: utest [number of threads]\n");
		exit();
	}
	tans = (int*)malloc(sizeof(int));

	num = atoi(argv[1]);
	threadsArr = (int*)malloc(sizeof(int)*num);

	bbuffer = BB_create(1);

	for (i = 0; i < num; ++i) {
		stack = malloc(STK_SZ);
		if (i % 3)
			threadsArr[i] = thread_create(&produce, stack, STK_SZ);
		else
			threadsArr[i] = thread_create(&consume, stack, STK_SZ);
	}

	for (i = 0; i < num; ++i) {
		thread_join(threadsArr[i], (void**)&tmp);
	}

*******/
	exit();
	return 1;
}



